<template>
  <div class="menu-button sa-flex sa-flex-wrap">
    <template v-for="(l, lindex) in compData.data.list" :key="l">
      <div
        class="menu-item"
        :style="{
          width: 100 / compData.data.col + '%',
        }"
        v-if="lindex < compData.data.row * compData.data.col"
      >
        <div
          class="badge"
          v-if="l.badge.show"
          :style="{ background: l.badge.bgColor, color: l.badge.color }"
        >
          {{ l.badge.text }}
        </div>
        <sa-image :url="l.src" size="40" radius="0" :suffix="null"></sa-image>
        <div v-if="compData.data.layout == 1" class="title" :style="{ color: l.title.color }">
          {{ l.title.text }}
        </div>
      </div>
    </template>
    <div class="indicator" v-if="compData.data.list.length > compData.data.row * compData.data.col">
      <sa-icon icon="sa-shop-decorate-imageBanner-indicator-1" size="30" />
    </div>
  </div>
</template>

<script setup>
  const props = defineProps(['compData']);
</script>

<style lang="scss" scoped>
  .menu-button {
    padding-bottom: 10px;
    .menu-item {
      display: flex;
      flex-direction: column;
      align-items: center;
      font-size: 16px;
      position: relative;
      margin: 6px 0 5px;
      .title {
        height: 16px;
        line-height: 16px;
        margin-top: 4px;
        font-size: 12px;
      }
      .badge {
        position: absolute;
        top: 0;
        left: 50%;
        z-index: 1;
        padding: 0 6px;
        height: 20px;
        line-height: 20px;
        font-size: 12px;
        text-align: center;
        border-radius: 6px 6px 6px 0;
      }
    }
    .indicator {
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      :deep() {
        .sa-icon {
          color: #333;
        }
      }
    }
  }
</style>
